unit JATUIF_Component_Matrix;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, Video, JATUIF_Component, JATUIF_Driver_Screen;

Type

    { TMatrix }

    TMatrix = class(TComponent)
      Protected
        Procedure _OnKeyPress(Key:Char); override;
        Procedure _OnMouseEnter; override;
        Procedure _OnMouseLeave; override;
        Procedure _OnClick; override;
        Procedure _OnLoseFocus; override;
        Procedure Draw; override;
      Private
        { Private Properties & Methods }
        ColX, ColY : Byte;
      Public
        Constructor Create(Parent:TScreen; X1,Y1,X2,Y2:Integer);
        Procedure New;
    end;

implementation

{ TMatrix }

constructor TMatrix.Create(Parent: TScreen; X1, Y1, X2, Y2: Integer);
begin
     inherited Create(Parent, X1, Y1, X2, Y2);
end;

procedure TMatrix.New;
begin
     Draw;
end;

procedure TMatrix.Draw;
Var
   i,n:integer;

begin
     For i:=Self.GetX1 to Self.GetX2 do begin
         For n:=Self.GetY1 to Self.GetY2 do begin
             If Random(100) > 50 then begin
                If Random(100) > 75 then begin
                   Screen.DrawCharXY(Self.GetTag,i,n,Char(48+Random(9)),Green,Black);
                end else begin
                    If Random(100) > 87 then begin
                       Screen.DrawCharXY(Self.GetTag,i,n,' ',Green,Black);
                    end else begin
                        Screen.DrawCharXY(Self.GetTag,i,n,Char(65+Random(25)),Green,Black);
                    end;
                end;
             end;
         end;
     end;
end;

{ Callback Events }

procedure TMatrix._OnKeyPress(Key: Char);
begin
     inherited _OnKeyPress(Key);
end;

procedure TMatrix._OnMouseEnter;
begin
     inherited _OnMouseEnter;
end;

procedure TMatrix._OnMouseLeave;
begin
     inherited _OnMouseLeave;
end;

procedure TMatrix._OnClick;
begin
     inherited _OnClick;
end;

procedure TMatrix._OnLoseFocus;
begin
     inherited _OnLoseFocus;
end;

end.

